<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');
 
class Gass_global_model extends CI_Model {
	
	// The following method prevents an error occurring when $this->data is modified.
	// Error Message: 'Indirect modification of overloaded property Demo_cart_admin_model::$data has no effect'.
	public function &__get($key)
	{
		$CI =& get_instance();
		return $CI->$key;
    }
    /**
     * 对系统提示信息（p标签包裹的数据）进行重新处理        
	 * 参数：系统生成的提示信息 
	 */ 
  function get_alert_message($message)
  {
      $message="<meta http-equiv='Content-Type' content='text/html;charset=utf-8'>".$message;
      $arr = array();  
      $doc = new DOMDocument();
      $doc->loadHTML($message);
      $params = $doc->getElementsByTagName('p');
      foreach ($params as $param) 
      {
          $arr[] = array( $param->getAttribute('class'),$param->nodeValue);
      }
      return $arr;   
 }
 

	/**
	 * 获取快速发送站内信所需的接收对象数据
	 *
	 * 主要包括招生二级单位名称和负责老师的ID号
	 */
	 function get_college_teacher_list(){
	 	
	 	 $this->db->select('*');
	 	 $this->db->from('ga_colleges');
	 	 $this->db->join('ga_user_profiles','ga_colleges.college_id=ga_user_profiles.upro_college_id');
	 	 return $this->db->get()->result_array();
	 	 
	 }	
	/**
	 * get_last_message_info
	 * 获取该会话最后一次通话的记录
	 */
	 function get_last_message_info($fId,$sId){
	 	 $this->db->select('*');
	 	 $this->db->from('message_list_view');
	 	 $where = "(send_id = '".$fId."' and rec_id = '".$sId."') or 
	 	           (send_id = '".$sId."' and rec_id = '".$fId."')";
	 	 $this->db->where($where);
	 	 $this->db->order_by('creat_time','desc');
	 	 $this->db->limit(1);
	 	 return $this->db->get()->row_array();
	 	 
	 }	
	/**
	 * get_cmt_array_by_series
	 * 根据专业序号获取专业名称
	 * 参数1：专业ID；参数2：导师ID
	 */	 
	 function get_cmt_array_by_series($series,$type){
	 	 $query='';
	 	 switch($type){
	 	 	case 1:
	 	 	  $query = $this->db->get_where('ga_college_major_tutor',array('major_id' => $series))->row_array();
	 	    return $query['major_name'];
	 	    break;
	 	 	case 2:
	 	 	  $query = $this->db->get_where('ga_college_major_tutor',array('tutor_id' => $series))->row_array();
	 	    return $query['tutor_name'];
	 	    break;
	 	 }
	 }
	/**
	 * 获取所有的分院信息
	 * 
	 * 获取重庆大学所有招收研究生的学院信息
	 */	 
	 function get_colleges_array()
	 {
	 	 return $this->db->get('ga_colleges')->result_array();
	 }	 
}
